package campus.service.impl;

import campus.mapper.AccountMapper;
import campus.mapper.CashMapper;
import campus.model.Account;
import campus.model.AccountExample;
import campus.model.Cash;
import campus.model.CashExample;
import campus.service.AccountService;
import campus.service.CashService;
import campus.util.PageResult;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
     * @Author M
     * @name  现金日记账
     * @Date 21:45 2020/5/10
 **/
@Service
public class CashServiceImpl implements CashService {

    @Autowired
    private CashMapper cashMapper;
    @Override
    public List<Cash> selectByExample(CashExample example) {
        return cashMapper.selectByExample(null);
    }


    @Override
    public PageResult findByAllPageSize(Cash cash, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        cash.setcStatus("0");
        Page<Cash> findlog = (Page<Cash>) cashMapper.findByAllPageSize(cash);
        return new PageResult(findlog.getTotal(),findlog.getResult());
    }

    @Override
    public PageResult findByAllPageSize2(Cash cash, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        cash.setcStatus("1");
        Page<Cash> findlog = (Page<Cash>) cashMapper.findByAllPageSize(cash);
        return new PageResult(findlog.getTotal(),findlog.getResult());
    }

    @Override
    public int deleteByPrimaryKey(Integer cId) {
        return cashMapper.deleteByPrimaryKey(cId);
    }

    @Override
    public int plscs(int[] ids) {
        for (int id: ids) {
            cashMapper.plscs(id);
        }
        return 0;
    }

}
